#include<bits/stdc++.h>
#define ll long long
#define L xd[x].l
#define R xd[x].r
#define mid (l+r>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define OK Ll<=l&&r<=Rr
#define Root 1,1,n
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define pb push_back
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(ll x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
using namespace std;
const int N =6e6+5,M=3.5e7+5,inf=(1LL<<31)-1,mod=998244353;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
string s[N];
int n,m,K,sx,sy,tx,ty;
int dis[N],ID[N];
bool vis[N];
inline bool ck(int X,int Y){
	return X&&Y&&X<=n&&Y<=m;
}
inline int id(int x,int y){
	return (x-1)*m+y;
}
inline Pi decode(int x){
	return {(x-1)/m+1,(x-1)%m+1};
}
struct seg{
	int l,r;
}xd[N];
int h[N],to[M],nxt[M],cnt,rt[N],tot;
bool w[M];
inline void add_(int a,int b,bool c){
	to[++cnt]=b,nxt[cnt]=h[a],h[a]=cnt,w[cnt]=c;
}
inline void build(int x,int l,int r,bool f,int k){
	if(l==r){
		if(f)add_(x,id(k,l),0);
		return;
	}
	L=++tot,R=++tot,add_(x,L,0),add_(x,R,0),build(lc,f,k),build(rc,f,k);
}
inline void Build(int y,int x,int l,int r){
	add_(y,x,0);
	if(l==r)return;
	Build(xd[y].l,lc),Build(xd[y].r,rc);
}
inline void modify(int x,int l,int r,int Ll,int Rr,int fr){
	if(Ll>Rr)return;
	if(OK)return add_(fr,x,1),void();
	if(Ll<=mid)modify(lc,Ll,Rr,fr);
	if(Rr>mid)modify(rc,Ll,Rr,fr);
}
#define LL x<<1,l,mid
#define RR x<<1|1,mid+1,r
inline void buildall(int x,int l,int r){
	rt[x]=++tot,build(rt[x],1,m,l==r,l);
	if(l==r)return ID[l]=rt[x],void();
	buildall(LL),buildall(RR); 
	Build(rt[x],rt[x<<1],1,m),Build(rt[x],rt[x<<1|1],1,m);
}
inline void Modify(int x,int l,int r,int Ll,int Rr,int le,int re,int fr){
	Ll=max(Ll,1),Rr=min(Rr,n),le=max(le,1),re=min(re,m);
	if(Ll>Rr||le>re)return;
	if(OK)return modify(rt[x],1,m,le,re,fr),void();
	if(Ll<=mid)Modify(LL,Ll,Rr,le,re,fr);
	if(Rr>mid)Modify(RR,Ll,Rr,le,re,fr);
}
inline void bfs(){
	queue<int>q[2];
	rep(i,1,tot)dis[i]=inf;
	dis[id(sx,sy)]=0,q[0].push(id(sx,sy));
	while(!q[0].empty()||!q[1].empty()){
		int x;
		if(!q[0].empty())x=q[0].front(),q[0].pop();
		else x=q[1].front(),q[1].pop();
		e(x)if(!w[i]&&dis[y]>dis[x]+w[i])dis[y]=dis[x]+w[i],q[0].push(y);
		if(x<=n*m){
			Pi now=decode(x);
			int i=now.first,j=now.second;
			rep(k,0,3){
				int X=i+dx[k],Y=j+dy[k];
				if(ck(X,Y)){
					if(s[X][Y]=='#')continue;
					int y=id(X,Y);
					if(dis[y]>dis[x])dis[y]=dis[x],q[0].push(y);
				}
			}
		}
		e(x)if(dis[y]>dis[x]+w[i])dis[y]=dis[x]+w[i],q[1].push(y);
	}
}
inline void subtask1(){
	buildall(Root);
	repn(i)repm(j){
		Modify(Root,i-K+1,i+K-1,j-K,j+K,id(i,j));
		if(i-K>=1)modify(ID[i-K],1,m,j-K+1,j+K-1,id(i,j));
		if(i+K<=n)modify(ID[i+K],1,m,j-K+1,j+K-1,id(i,j));
	}
	bfs();
	cout <<dis[id(tx,ty)];
}
inline void Main(){
	n=read(),m=read(),tot=n*m,K=read();
	sx=read(),sy=read(),tx=read(),ty=read();
	repn(i)cin>>s[i],s[i]='#'+s[i];
	subtask1();
}
signed main(){
	freopen("stamp.in","r",stdin);
	freopen("stamp.out","w",stdout);
	int T=1;
	while(T--)Main(); 
	return 0;
}
